
<?php include_once("header.html")?>


<div id="wrap">  <br />
  <div class="tabsA">
    	<div class="left">

        	<div class="right"><?php echo lang("registration");?></div>
        </div>
      <div class="des"><?php echo lang("already_signup");?> <a href="<?php echo $www_site_url?>/index.php/passport/login"><?php echo lang("login");?>!</a></div>
  </div>
  <div class="<?php echo lang("regstepclass");?> clear"></div>
  <div class="regInfo">

<FORM name="registerform" id="registerform" method="POST" onsubmit="return checkOnSubmit('registerform', rules);" >
<input type="hidden" name="action" value="passport">
<input type="hidden" name="op" value="saveuser">
<input type="hidden" name="reg_type" value="<?php echo $reg_type?>">

<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD width="40%" class="text"></TD>
<TD width="60%"><div id="msg" style="margin:0 auto;"></div></TD>
</TR>
<TR>
<TD class="text"><?php echo lang('invitation_code')?>:</TD>
<TD><div id="errorsDiv_invitationcode"></div><INPUT type="text" name="invitationcode" id="invitationcode" class="input" style="width:100px"/></TD>
</TR>
<?php if($reg_type=='email') {?>

<TR>
<TD width="40%" class="text"><?php echo lang('email')?>:</TD>
<TD width="60%"><div id="errorsDiv_email"></div><INPUT class="input" type="text" name="email" value="<?php echo $email?>" id="email" /></TD>
</TR><?php } ?>
<?php if($reg_type=='username') {?><TR>
<TD width="120px"><?php echo lang('username')?>:</TD>
<TD><div id="errorsDiv_username"></div><INPUT class="input" type="text" name="username"  value="<?php echo $username?>" id="username"/>
</TD>
</TR><?php } ?>
<TR><TD class="text"><?php echo lang('pwd')?>:</TD>
<TD><div id="errorsDiv_password"></div><INPUT class="input" type="password" name="password"  /></TD>
</TR>
<TR>
<TD class="text"><?php echo lang('comfirmpwd')?>:</TD>
<TD><div id="errorsDiv_comfirmpwd"></div><INPUT class="input" type="password" name="comfirmpwd"  /></TD>
</TR>
<?php if($reg_type=='username') {?>
<TR>
<TD class="text"><?php echo lang('pwdquestion')?>:</TD>
<TD><div id="errorsDiv_question"></div><select class="input" id="question" name="question" title="<?php echo lang('pwdquestion')?>">

			<option value="" selected="selected" ><?php echo lang('selectaquestion')?></option>

			<option value="<?php echo lang('q1')?>" ><?php echo lang('q1')?></option>			

			<option value="<?php echo lang('q2')?>" ><?php echo lang('q2')?></option>

			<option value="<?php echo lang('q3')?>" ><?php echo lang('q3')?></option>

			<option value="<?php echo lang('q4')?>" ><?php echo lang('q4')?></option>

			<option value="<?php echo lang('q5')?>" ><?php echo lang('q5')?></option>

			<option value="<?php echo lang('q6')?>" ><?php echo lang('q6')?></option>			

			<option value="<?php echo lang('q7')?>" ><?php echo lang('q7')?></option>

			<option value="<?php echo lang('q8')?>" ><?php echo lang('q8')?></option>

			<option value="<?php echo lang('q9')?>" ><?php echo lang('q9')?></option>

			<option value="<?php echo lang('q10')?>" ><?php echo lang('q10')?></option>
			
		</select></TD>
		</TR>
<TR>
<TD class="text"><?php echo lang('youranswer')?>:</TD>
<TD><div id="errorsDiv_answer"></div><INPUT class="input" type="text" name="answer" /></TD>
</TR>
<?php }?>

<TR>
<TD class="text"><?php echo lang('nickname')?>:</TD>
<TD><div id="errorsDiv_nickname"></div><INPUT class="input" type="text" name="nickname" value="<?php echo $nickname?>" /></TD>
</TR>
<TR>
<TD class="text"><?php echo lang('sex')?>:</TD>
<TD><div id="errorsDiv_sex"></div><INPUT type="radio" name="sex" value="1" <?php if($select_sex==1) echo 'checked';?> /><?php echo lang('boy')?> <INPUT type="radio" name="sex" value="2" <?php if($select_sex==2) echo 'checked';?>/><?php echo lang('girl')?>&nbsp;&nbsp;</TD>
</TR>


<TR>
<TD class="text"><?php echo lang('validatecode')?>:</TD>
<TD><div id="errorsDiv_code"></div><INPUT type="text" name="code" class="input" style="width:100px"/><img id="codeimg" src="<?php echo $www_site_url?>/index.php/identifycode/generate" align="absmiddle" title="<?php echo lang('anotherone')?>" onClick="changeCode();" style="cursor:pointer"></TD>
</TR>
<TR>
<TD class="text"></TD>
<TD><div id="errorsDiv_checkit"></div><INPUT type="checkbox" name="checkit" id="checkit" /> <a href="/index.php/index/protocol" target="_blank"><?php echo lang('protocol')?></a></TD>
</TR>

<TR><TD class="text">&nbsp;</TD><TD><input name="button" type="submit" class="btn" id="registerbtn" value="<?php echo lang('signup')?>" />

</TD></TR>
</TABLE>
</form>

<SCRIPT>
//only for test purposes
function checkOnSubmit(formName, r) {
   // document.getElementById(yav_config.errorsdiv).className = '';
   // document.getElementById(yav_config.errorsdiv).style.display = 'none';
   // var alertType = document.getElementById('alertType').value;
    if (yav.performCheck(formName, r, 'inline')) {
    	
    	var url = "<?php echo $www_site_url?>/index.php";
		var params = mini.form.serialize($(formName));
		mini.ajax.post(url, function(r){
			var r = eval('(' + r + ')');   
			if(r.s==200){
				window.location.href = r.d;
			}
			if(r.s==400){
				$('msg').innerHTML = r.m;			
			}
		}, params);
    	
    	return false;
       
    } 
    return false;
}

var rules=new Array();
rules[0]='username|required|<?php echo lang('usernamerule')?>';
rules[1]='username|regexp|^[a-zA-Z][a-zA-Z0-9_]{1,13}[a-zA-Z0-9]$|<?php echo lang('usernamerule')?>';
rules[2]='email|required|<?php echo lang('insertemail')?>';
rules[3]='email|email|<?php echo lang('insertemail')?>';
rules[4]='password|required|<?php echo lang('insertpwd')?>';
rules[5]='password|minlength|6|<?php echo lang('pwdrule')?>';
rules[6]='comfirmpwd|equal|$password|<?php echo lang('pwdnotsame')?>';

rules[7]='sex|required|<?php echo lang('sexrule')?>';
rules[8]='code|required|<?php echo lang('coderule')?>';
rules[9]='nickname|required|<?php echo lang('nicknamerule')?>';

rules[10]='nickname|minlength|2|<?php echo lang('nicknamerule')?>';
rules[11]='nickname|maxlength|16|<?php echo lang('nicknamerule')?>';
rules[12]='question|required|<?php echo lang('selectaquestion')?>';
rules[13]='answer|required|<?php echo lang('youranswer')?>';
rules[14]='invitationcode|required|<?php echo lang('invitation_code_label')?>';
rules[15]='checkit|required|<?php echo lang('checkit_label')?>';


yav.addHelp('username', '<?php echo lang('usernamerule')?>');
yav.addHelp('password', '');
yav.addHelp('comfirmpwd', '');
yav.addHelp('email', '<?php echo lang('insertemail')?>');
yav.addHelp('question', '');
yav.addHelp('answer', '');
yav.addHelp('nickname', '');
yav.addHelp('sex', '');
yav.addHelp('code', '');
yav.addHelp('invitationcode', '');
yav.addHelp('checkit', '');
yav.postValidation_OnOK('email', 'blur', 'ajaxCall("email")');
yav.postValidation_OnOK('username', 'blur', 'ajaxCall("username")');



var captchaOK = 2;  // 2 - not yet checked, 1 - correct, 0 - failed
var account = '';
// a simple ajax implementation

function ajaxCall(s) {
	account = s;
	mini.ajax.get("<?php echo $www_site_url?>/index.php?action=passport&view=checkuser&user=" + escape(document.getElementById(s).value), function(r){
	    captchaOK = r;  
	    if(captchaOK != 1) {              
	      	yav.displayMsg(account, '<?php echo lang('userexist')?>', yav_config.innererror);
	      	document.registerform.registerbtn.disabled=true;
	      	return false;
	      } else {
	          yav.displayMsg(account, '<?php echo lang('userisok')?>', yav_config.innerhelp);      
	          document.registerform.registerbtn.disabled=false;
	          return true;
	      }
	});  
    return false;
}

function changeCode() {
	var num = 	new Date().getTime();
	var rand = Math.round(Math.random() * 10000);
	num = num + rand;
	document.getElementById("codeimg").src = "<?php echo $www_site_url?>/index.php/identifycode/generate/" + num;
	return false;
}
window.onload = function(){
	yav.init('registerform', rules);
}
</SCRIPT>
<p>&nbsp;</p>
  </div>
</div>
</div>
<?php include_once("footer.html")?>
